package com.zlp.mall.portal.modules.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zlp.mall.portal.modules.pms.mapper.ProductAttributeMapper;
import com.zlp.mall.portal.modules.pms.model.ProductAttribute;
import com.zlp.mall.portal.modules.pms.model.ProductAttributeValue;
import com.zlp.mall.portal.modules.pms.service.ProductAttributeService;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <p>
 * 商品属性参数表 服务实现类
 * </p>
 *
 * @author ZouLiPing
 * @since 2021-10-13
 */
@Service
public class ProductAttributeServiceImpl extends ServiceImpl<ProductAttributeMapper, ProductAttribute> implements ProductAttributeService {


    @Override
    public String getByAttrValueId(Long attributeValueId) {

        String attrName = null;
        LambdaQueryWrapper<ProductAttribute> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProductAttribute::getId,attributeValueId);
        queryWrapper.last(" limit 1");
        ProductAttribute one = this.getOne(queryWrapper);
        if (Objects.nonNull(one)) {
            attrName = one.getName();
        }
        return attrName;
    }
}
